// app/service/sync.js
const { Service } = require('egg');

class SyncService extends Service {
  async resumeSync(lastSyncKey) {
    const checkpoint = await this.ctx.app.redis.get(lastSyncKey);
    const result = await this.ctx.curl(`${this.config.api}/resume`, {
      headers: {
        'Range': `bytes=${checkpoint || 0}-`
      }
    });

    await this.ctx.service.zcyCrypto.verifyDataHash(result.data);
    await this._processWithCheckpoint(result.data);
  }
}

module.exports = SyncService;